package messages;

public enum MessageType
{
    //General
    GeneralAck(0x55),
    DeregistrationMessage(0x7F),
    KillOrderMessage(0x66),
    
    //Elevator Messages
    ElevatorStatusMessage(0x01),
    ElevatorStatusRequest(0x02),
    HallCallAssignmentMessage(0x05),
    HallCallRevokeMessage(0x06),
    
    //Observer Messages
    CurrentStateMessage(0x3E),
    CurrentStateRequest(0x3D),
    EventCollectionMessage(0x32),
    
    //Person Dispatcher Messages
    RegisterHallCallMessage(0x2E),
    CurrentPeopleStateMessage(0x3B),
    CurrentPeopleStateRequest(0x3C),
    
    PersonCreationMessage(0x4B),
    
    //Registration Messages
    ElevatorRegistrationMessage(0x0F),
    ElevatorRegistrationMessageAck(0x0E),
    ObserverRegistrationMessage(0x3F),
    PersonDispatcherRegistrationMessage(0x2F),
    
    //UDP Messages
    PersonTransferMessage(0x11),
    PersonInElevatorMessage(0x12),
    PersonPressButtonMessage(0x13),
    PersonOutElevatorMessage(0x14),
    
    ;
    
    private byte identifier;
    
    private MessageType(int identifier)
    {
        this.identifier = (byte) identifier;
    }
    
    public byte getIdentifier()
    {
        return identifier;
    }
    
    public static MessageType getMessageTypeForId(byte identifier)
    {
        for (MessageType t : MessageType.values())
        {
            if (identifier == t.getIdentifier())
            {
                return t;
            }
        }
        
        return null;
    }
    
}
